package myJqueryOne.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fasterxml.jackson.databind.ObjectMapper;

import myJqueryOne.service.StaffService;
import myJqueryOne.service.impl.StaffServiceImpl;

public class StaffServlet extends HttpServlet {
	private static ObjectMapper mapper = new ObjectMapper();
	static StaffService staffService=new StaffServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		resp.setCharacterEncoding("UTF-8");
		String method=req.getParameter("methond");
		if("list".equals(method)) {
			list(req,resp);
		}
	}
	private void list(HttpServletRequest req, HttpServletResponse resp) throws IOException {

		String branchCode=req.getParameter("branchCode");
		PrintWriter out =resp.getWriter();
		out.print(mapper.writeValueAsString(staffService.listAll(branchCode)));
		
	}
										 
}
